package com.jobboard.subject.application.controller;

import com.jobboard.subject.common.entity.PageResult;
import com.jobboard.subject.infra.basic.entity.SubjectInfoEs;
import com.jobboard.subject.infra.basic.service.SubjectEsService;
import com.jobboard.subject.infra.entity.UserInfo;
import com.jobboard.subject.infra.rpc.UserRpc;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 刷题controller
 */
@RestController
@RequestMapping("/subject/info")
@Slf4j
public class TestFeignController {

    @Resource
    private UserRpc userRpc;


    @Resource
    private SubjectEsService subjectEsService;

    @RequestMapping("/testFeign")
    public void testFeign() {
        UserInfo userInfo = userRpc.getUserInfo("o-XTU6my2_l5t_Hk1n-ED0E3SpSk");
        log.info("testFeign.userInfo:{}", userInfo);
    }

//    @RequestMapping("/testCreateIndex")
//    public void testCreateIndex() {
//        subjectEsService.createIndex();
//    }
//
//    @RequestMapping("/addDocs")
//    public void addDocs() {
//        subjectEsService.addDocs();
//    }
//
//    @RequestMapping("/find")
//    public void find() {
//        subjectEsService.find();
//    }
//
//    @RequestMapping("/search")
//    public void search() {
//        subjectEsService.search();
//    }

    @PostMapping("/SubjectPageBySearch")
    public void testSubjectPageBySearch() {
        SubjectInfoEs subjectInfoEs = new SubjectInfoEs();
        subjectInfoEs.setKeyWord("mysql");
        PageResult<SubjectInfoEs> pageResult = subjectEsService.querySubjectList(subjectInfoEs);
        log.info("testSubjectPageBySearch:{}", pageResult);
    }
}
